<include file="Public/head" xmlns="http://www.w3.org/1999/html"/>
<include file="Public/common_header" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/css/cashier.css" />
<div class="mian">
    <include file="Public/sidebar" menu="clcwht.tpsh"  />
    <div class="mianR">
    	<div style="display:none;" id="inputBox">
    		
    	</div>
        <div class="yuyue">
            <ul>
                <li onclick="getAuditPicList(2,1);" class="yuCurrent">待审核</li>
				<li onclick="getAuditPicList(1,1);">已通过</li>
            </ul>
        </div>
        <div class="listBox" id="listBox">
        	<div class="yuList">
        		<div class="audit-picture-title" id="pending-audit">
        		</div>
        	</div>
        	<div class="yuList" style="display: none;">
        		<div class="audit-picture-title" id="already-passed">
        		</div>
        	</div>       	
        </div>
    </div>
</div>
 <div class="yunBei"></div>
<div class="loading"></div>
<script>

var questionList = [];
var question_num = 0;

function audit(obj){
	var num=0;			
	$(obj).find("ul li").on("click",function(){		
		var id = $(this).children('img').attr('data');
		if($(this).hasClass("cuurent")){
			num--;		
			$(this).removeClass("cuurent");				
			$(obj).find(".audit-title").find(".stretched").html(num);
			$('#img_'+id).remove();
			$('#passed_id').append('<input type="hidden" id="audit_'+id+'" value="'+id+'" />');
		}else{
			$('#inputBox').append('<input type="hidden" id="img_'+id+'" value="'+id+'" />');
			$('#audit_'+id).remove();
			num++;
			$(this).addClass("cuurent");
			$(obj).find(".audit-title").find(".stretched").html(num);	
		}		
		
		questionList = [];
		$(obj).find("ul li.cuurent").each(function(){
			var questionid = $(this).children('img').attr('questionid');
			questionList[questionid] = 1;
			
		});
		question_num = 0;
		for(var i in questionList){
			question_num ++;
		}
		$('.question_num').html(question_num);
		
	})
}	

audit("#already-passed");
	
var p = 0;
var s = 2;
function getAuditPicList(status,page){
	$('#inputBox').val('');
	p = page;
	s = status;
	$.get('/Question/getPicList',{status:status,p:page}, function(data){
		if(status == 2){
			$('#pending-audit').html(data);
			audit("#pending-audit");
		}else{
			$('#already-passed').html(data);
			audit("#already-passed");
		}
		
	});
}
getAuditPicList(2,1);


function get_page(page){
	getAuditPicList(s,page);
}
function doAudit(){
	var illegal = [];
	$('#inputBox input').each(function(){
		illegal.push($(this).val());
	});
	
	var pass = [];
	$('#passed_id input').each(function(){
		pass.push($(this).val());
	});

	$.post('/Question/audit', {illegal:illegal,pass:pass}, function(data){
		if(data.code == 200){
			get_page(p);
		}else{
			alert('图片审核失败，请重试');
		}
	},'json');
}

function delPic(){
	var illegal = [];
	$('#inputBox input').each(function(){
		illegal.push($(this).val());
	});

	$.post('/Question/delPic', {illegal:illegal}, function(data){
		if(data.code == 200){
			get_page(p);
		}else{
			alert('图片删除失败，请重试');
		}
	},'json');
}
	
</script>
<include file="Public/foot" />